/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.models.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrator
 */
@Entity
@Table(name = "tblQuestion", catalog = "cungonbaiDB", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TblQuestion.findAll", query = "SELECT t FROM TblQuestion t"),
    @NamedQuery(name = "TblQuestion.findByQuestionId", query = "SELECT t FROM TblQuestion t WHERE t.questionId = :questionId"),
    @NamedQuery(name = "TblQuestion.findByQuestionContent", query = "SELECT t FROM TblQuestion t WHERE t.questionContent = :questionContent"),
    @NamedQuery(name = "TblQuestion.findByQuestionLevel", query = "SELECT t FROM TblQuestion t WHERE t.questionLevel = :questionLevel"),
    @NamedQuery(name = "TblQuestion.findByType", query = "SELECT t FROM TblQuestion t WHERE t.type = :type"),
    @NamedQuery(name = "TblQuestion.findByQuestionCode", query = "SELECT t FROM TblQuestion t WHERE t.questionCode = :questionCode")})
public class TblQuestion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "questionId", nullable = false)
    private Integer questionId;
    @Size(max = 1073741823)
    @Column(name = "questionContent", length = 1073741823)
    private String questionContent;
    @Column(name = "questionLevel")
    private Integer questionLevel;
    @Column(name = "type")
    private Integer type;
    @Size(max = 200)
    @Column(name = "questionCode", length = 200)
    private String questionCode;
    @JoinTable(name = "tblTopic_Question", joinColumns = {
        @JoinColumn(name = "questionId", referencedColumnName = "questionId", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "topicId", referencedColumnName = "topicId", nullable = false)})
    @ManyToMany
    private List<TblTopic> tblTopicList;
    @JoinColumn(name = "userId", referencedColumnName = "userId")
    @ManyToOne
    private TblUser userId;
    @JoinColumn(name = "subjectId", referencedColumnName = "subjectId")
    @ManyToOne
    private TblSubject subjectId;
    @OneToMany(mappedBy = "questionId")
    private List<TblUserAnswer> tblUserAnswerList;
    @OneToMany(mappedBy = "questionId")
    private List<TblAnswer> tblAnswerList;

    public TblQuestion() {
    }

    public TblQuestion(Integer questionId) {
        this.questionId = questionId;
    }

    public Integer getQuestionId() {
        return questionId;
    }

    public void setQuestionId(Integer questionId) {
        this.questionId = questionId;
    }

    public String getQuestionContent() {
        return questionContent;
    }

    public void setQuestionContent(String questionContent) {
        this.questionContent = questionContent;
    }

    public Integer getQuestionLevel() {
        return questionLevel;
    }

    public void setQuestionLevel(Integer questionLevel) {
        this.questionLevel = questionLevel;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getQuestionCode() {
        return questionCode;
    }

    public void setQuestionCode(String questionCode) {
        this.questionCode = questionCode;
    }

    @XmlTransient
    public List<TblTopic> getTblTopicList() {
        return tblTopicList;
    }

    public void setTblTopicList(List<TblTopic> tblTopicList) {
        this.tblTopicList = tblTopicList;
    }

    public TblUser getUserId() {
        return userId;
    }

    public void setUserId(TblUser userId) {
        this.userId = userId;
    }

    public TblSubject getSubjectId() {
        return subjectId;
    }

    public void setSubjectId(TblSubject subjectId) {
        this.subjectId = subjectId;
    }

    @XmlTransient
    public List<TblUserAnswer> getTblUserAnswerList() {
        return tblUserAnswerList;
    }

    public void setTblUserAnswerList(List<TblUserAnswer> tblUserAnswerList) {
        this.tblUserAnswerList = tblUserAnswerList;
    }

    @XmlTransient
    public List<TblAnswer> getTblAnswerList() {
        return tblAnswerList;
    }

    public void setTblAnswerList(List<TblAnswer> tblAnswerList) {
        this.tblAnswerList = tblAnswerList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (questionId != null ? questionId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblQuestion)) {
            return false;
        }
        TblQuestion other = (TblQuestion) object;
        if ((this.questionId == null && other.questionId != null) || (this.questionId != null && !this.questionId.equals(other.questionId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.models.entities.TblQuestion[ questionId=" + questionId + " ]";
    }
    
}
